package com.heima.leadnews.article.listener;

import com.heima.leadnews.article.service.ApArticleConfigService;
import com.heima.model.common.constant.CommonConstant;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class TopicDownUpListener {

    @Autowired
    private ApArticleConfigService apArticleConfigService;

    @KafkaListener(topics = CommonConstant.TOPIC_DOWN_UP)
    public void receiveMessage(ConsumerRecord<String,String> consumerRecord){
        String articleId = consumerRecord.key();
        String enable  = consumerRecord.value();
        apArticleConfigService.updateIsDown(articleId,enable);
    }
}
